package com.example.myapplication2

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.activity_second.*

class SecondActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)
        var extraData = intent.getIntExtra("extra_data",-1)
        extraData++
        Log.d("SecondActivity", "extra data is $extraData")
        button2.setOnClickListener {
            val intent = Intent()
            intent.putExtra("data_return", 20)
            setResult(RESULT_OK, intent)
            finish()
        }
    }
    override fun onBackPressed() {
        val intent = Intent()
        intent.putExtra("data_return", 23)
        setResult(RESULT_OK, intent)
        finish()
    }
}